local Gameplay = GameState:addState('Gameplay')

function Gameplay:enterState()
	print("GAMEPLAY enter state")
	
	Game.state = "gameplay"
	
	
	local rt = MOAIRenderMgr:getRenderTable()
	
	for key, value in pairs(rt) do
		if key ~= #rt then
			rt[key]:setVisible(true)
		end
		
	end
	if Game.initial_state == true then -- the current one and true entry point from a fresh new game
	
		Game:space_bg()
		local ship = ConstructManager:spawn_ship(ShipLayouts.a, 
			40, 100, ShipLayouts.offsets.a, ShipLayouts.tube_map.a)
		local dock = ConstructManager:spawn_dock(160, 95, 10)
	
		dock:hooker( nil, ship)
		
		
		Game:start_uts()
		Game.initial_state = false
		HUD:draw_uts()


		
		--local exp = Explosion.new(40, 100, 4, 100, 50)
		--exp:impact()
		--exp:impact(160, 95)
		--exp:impact(200, 200)
		--exp:impact(400, 100)
		
	else
	
		-- resume game timers on
		-- returns to gameplay state
	
		TM:start_all()
		
	end
	
	local a

end

function Gameplay:exitState()
	print("GAMEPLAY exit state")
	
	TM:pause_all()
	
	local top_layer = #MOAIRenderMgr.getRenderTable()+1
	Game:render_layer(gui:layer(), nil, top_layer)
	
	local rt = MOAIRenderMgr:getRenderTable()
	
	
	for key, value in pairs(rt) do
		if key ~= #rt then
			rt[key]:setVisible(false)
		end
		
	end

end